package servidor;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.SwingConstants;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class VentanaMaxConexiones extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JPanel contentPane;
	private JTextField textField;

	

	/**
	 * Create the frame.
	 */
	public VentanaMaxConexiones() {
		setTitle(".:: Conexiones M\u00E1ximas ::.");
		
		setBounds(100, 100, 500, 200);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		ImageIcon imgAceptar = new ImageIcon("imagenes/boton_aceptar.png");
		JButton btnAceptar = new JButton("New button");
		btnAceptar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				VentanaServidor.panelPrincipal.lblConex.setText(textField.getText());
				Servidor.conexinesMaximas = Integer.parseInt(textField.getText());
				dispose();
			}
		});
		btnAceptar.setBounds(186, 100, 117, 30);
		btnAceptar.setIcon(imgAceptar);
		contentPane.add(btnAceptar);
		
		JLabel lblConexMximas = new JLabel("CONEXIONES M\u00C1XIMAS:");
		lblConexMximas.setHorizontalAlignment(SwingConstants.CENTER);
		lblConexMximas.setFont(new Font("Times New Roman", Font.BOLD, 14));
		lblConexMximas.setBounds(30, 49, 180, 31);
		contentPane.add(lblConexMximas);
		
		textField = new JTextField();
		textField.setFont(new Font("Times New Roman", Font.PLAIN, 14));
		textField.setBounds(237, 49, 180, 31);
		contentPane.add(textField);
		textField.setColumns(10);
		
		setLocationRelativeTo(null);
		setVisible(true);
		setResizable(false);
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	}
}
